package com.langfeiyes.pattern.observer.demo3;


import java.util.Observable;
import java.util.Observer;

//观察者：消费者
public class ConsumerObserver implements Observer {
    private String name;
    public ConsumerObserver(String name){
        this.name = name;
    }
    @Override
    public void update(Observable o, Object arg) {
        ProductObserver po = (ProductObserver) o;
        if(po.hasChanged()){
            System.out.println(this.name + "：心念念的"+po.getName()+"，终于到啦，抢呀~");
        }else{
            System.out.println(this.name + "小明：还没到啊，花都谢了~");
        }
    }
}
